﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HRM.DAL.DAO;
using HRM.DAL.Gateway;

namespace HRM.BLL
{
    public class PhotoManager
    {
        PhotoGateway gateway=new PhotoGateway();
        public bool SavePhoto(Photo photo)
        {
            EmployeeGateway empGateway=new EmployeeGateway();
            int empId = empGateway.GetEmployeeID(photo.Employee.EmpCode);
            if(gateway.HasPhotoAlreadyExist(empId))
            {
               return gateway.UpdatePhoto(empId, photo);
            }
            else
            {
                return gateway.SavePhoto(empId, photo);
            }
        }
        public Photo GetPhoto(Photo photo)
        {
            EmployeeGateway empGateway = new EmployeeGateway();
            int empId = empGateway.GetEmployeeID(photo.Employee.EmpCode);
            return gateway.GetPhoto(empId);
        }
    }
}